import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToMany, JoinTable } from "typeorm";
import { Permission } from "./permission.entity";

@Entity({
    name: "roles"
})
export class Role {

    @PrimaryGeneratedColumn()
    id: number;

    @Column({
        length: 20,
        comment: "角色名称"
    })
    name: string;

    @CreateDateColumn()
    createTime: Date;

    @UpdateDateColumn()
    updateTime: Date;

    @ManyToMany(()=>Permission)
    @JoinTable({
        name: "role_permission"
    })
    permissions: Permission[]
}